// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import * as filters from './filters'//引入过滤器
import ElementUI from 'element-ui';//引入饿了么ui的全部组件
import 'element-ui/lib/theme-chalk/index.css';//引入elementui的css
import 'video.js/dist/video-js.css'//引入video-js样式
import VueParticles from 'vue-particles'//引入粒子动画
import dataV from '@jiaminghi/data-view';//引入大屏常用组件



import api from './api/index.js'
import util from '@/common/util'

//全局引用大屏插件
Vue.use(dataV);
//全局引用粒子动画
Vue.use(VueParticles)
//全局引用elementui组件
Vue.use(ElementUI);
//全局引用所有的过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

router.onError((error) => {
  const pattern = /Loading chunk (\d)+ failed/g;
  const isChunkLoadFailed = error.message.match(pattern);
  const targetPath = router.history.pending.fullPath;
  if (isChunkLoadFailed) {
    router.replace(targetPath);
  }
});


Vue.prototype.$http = api
Vue.prototype.$util = util
Vue.config.productionTip = false

document.title = util.title_name

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  render: h => h(App)
})
